package cn.ncupyh;

public class Exception {
    public static void main(String[] args) {
        //运行异常
        int num1 = 3;
        int num2 = 0;
        test1(3,0);

//       会报异常: Exception in thread "main" java.lang.ArithmeticException: / by zero
        //注意:除法运算中,除数不为0;
    }
    static void test1(int n, int m){
        int num3 ;

        //操作方法:将鼠标至于要判断异常的一行,按住: ctrl + alt + T
        try {
            num3 = n/m;
        } catch (java.lang.Exception e) {
            System.out.println("异常为: " + e.getMessage());
        }

//        System.out.println(num3);
    }
}
